﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OracleClient;
using BCNPCObject.DB;
using DbLinq;
using DbLinq.Oracle;
using CMISLibrary.Entities;
using CMISLibrary;

namespace BCNPCObject
{
    public class cls_NPC_BCTSKT_Controller
    {
        #region   Atributes

        private DataSet CMIS_Header = new CMISOutputParameter();
        private DataSet ds = new DataSet();
        private DataTable dt = new DataTable();
        private NPC_BCTSKT info;

        #endregion

        #region   Constructor

        public cls_NPC_BCTSKT_Controller()
        {
            info = new NPC_BCTSKT();
        }
        public cls_NPC_BCTSKT_Controller(NPC_BCTSKT Info)
        {
            this.info = Info;
        }

        #endregion

        #region   Properties

        public NPC_BCTSKT pInfor
        {
            get { return info; }
            set { info = value; }
        }

        #endregion

        #region  DungNT NPC

        public IEnumerable<NPC_BCTSKT> getNPC_BCTSKT(string p_madonvi, Int16 p_thang, Int16 p_nam)
        {
            //DataSet ds = new DataSet();
            //DataTable dt = new DataTable();
            try
            {
                var q = from p in CMIS2.DB.NPC_BCTSKT
                        where p.MA_DVIQLY == p_madonvi
                        && p.THANG == p_thang && p.NAM == p_nam
                        orderby p.MA_LO
                        select p;
                   
                return q;
            }
            catch
            {
                CMIS2.ResetDB();
                return null;
            }
        }
        public bool update_BCTSKT()
        {
            try
            {
                NPC_BCTSKT obj_NPC_BCTSKT = CMIS2.DB.NPC_BCTSKT.Single(c => c.MA_DVIQLY == info.MA_DVIQLY && c.MA_LO == pInfor.MA_LO && c.THANG==pInfor.THANG && c.NAM== pInfor.NAM);
                obj_NPC_BCTSKT.TDL_MBA = pInfor.TDL_MBA;
                obj_NPC_BCTSKT.TSO_MBA = pInfor.TSO_MBA;
                obj_NPC_BCTSKT.SOMBA_CD = pInfor.SOMBA_CD;
                obj_NPC_BCTSKT.SOMBA_SC = pInfor.SOMBA_SC;
                obj_NPC_BCTSKT.SOMBA_CC = pInfor.SOMBA_CC;
                obj_NPC_BCTSKT.DLMBA_CC = pInfor.DLMBA_CC;
                obj_NPC_BCTSKT.DLMBA_SC = pInfor.DLMBA_SC;
                obj_NPC_BCTSKT.DLMBA_CD = pInfor.DLMBA_CD;
                CMIS2.DB.NPC_BCTSKT.UpdateOnSubmit(obj_NPC_BCTSKT);
                return true;
            }
            catch
            { return false; }
        }
        #endregion
    }


}

